
//获取应用实例
const app = getApp();
var commonData = require('../../data/data.js');
Page({
  data: {
    powers: [],
    height: 0,
    userId:"",
    currentPowerItem:{},
    isPowerShow:false
  },
  requestDataList: function (userId) {
    var that = this;
    wx.request({
      url: app.appSetting.host + "weixin/GetUserCats?userId=" + userId,
      data: {
      },
      header: {
        'content-type': 'application/json' // 默认值
      },
      success: function (res) {
        console.log(res);
        if (res.data.Status == 0) {
          that.setData({
            powers: res.data.Result,
            height: commonData.screenInfo.height
          });
        } else {
          app.showMsg(res.data.Message);
        }

      }
    })
  },
  getInstanceById: function (id, list) {
    var res = null;
    for (var i = 0; i < list.length; i++) {
      if (id == list[i].id) {
        res = list[i];
        break;
      }
    }
    return res;
  },

  showDetail: function (e) {
    var id = e.currentTarget.dataset.id;
    var instance = this.getInstanceById(id, this.data.powers);

    this.setData({
      currentPowerItem: instance,
      isPowerShow: true
    })

  },
  hideDetail: function (e) {
      this.setData({
        currentPowerItem: {},
        isPowerShow: false
      })   
  },
  onLoad: function (option) {
    this.requestDataList(option.userId);
    this.getSystermMsg();
  },
  //获取屏幕高度，宽度
  getSystermMsg: function () {
    var that = this;
    wx.getSystemInfo({
      success: function (res) {
        commonData.screenInfo.height = res.windowHeight;
        that.setData({
          height: res.windowHeight
        })
      }
    })
  },
  onShow: function (e) {
   
    //this.requestDataList();
  },



})
